package com.bac.rentmap.ad.flat.transform;

import com.bac.rentmap.ad.flat.crawler.FlatCrawledAd;
import com.bac.rentmap.ad.flat.jdo.JdoFlatAdDao;

import java.util.Arrays;
import java.util.Collection;
import java.util.logging.Logger;

/**
 * Created by osa on 4/2/2015.
 */
public class PhoneBlackListService {
    private static final Logger log = Logger.getLogger(PhoneBlackListService.class
            .getName());
    private Collection<String> phones = Arrays.asList(new String[]{"80447777171", "80297777767", "80296546448"});

    public boolean isInBlackList(FlatCrawledAd flatCrawledAd){
        boolean res = phones.contains(flatCrawledAd.getPhone());
        if(res) {
            log.info("BlackList check failed for phone:" + flatCrawledAd.getPhone());
            return true;
        }
        String description = flatCrawledAd.getDescription();
        if(description != null) {
            for (String phone : phones) {
                if (description.contains(phone)){
                    log.info("BlackListed phone " + phone + " found in the description:" + description);
                    return true;
                }
            }
        }
        return false;
    }
}
